package cn.wjssl.domain.strategy.service.rule.chain.impl;

import cn.wjssl.domain.strategy.service.armory.IStrategyDispatch;
import cn.wjssl.domain.strategy.service.rule.chain.AbstractLogicChain;
import cn.wjssl.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author：lxd
 * @Description 默认抽奖方式
 * @Date：2025/2/10
 */

@Slf4j
@Component("rule_default")
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    private IStrategyDispatch dispatch;

    @Override
    protected String currentRuleModel() {
        return DefaultChainFactory.LogicModel.RULE_DEFAULT.getCode();
    }

    /**
     * 默认抽奖
     * @param userId     用户ID
     * @param strategyId 策略ID
     * @return 责任链奖品流转对象
     */
    @Override
    public DefaultChainFactory.StrategyAwardVO logicChain(String userId, Long strategyId) {
        Integer awardId = dispatch.getRandomAwardId(strategyId);
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId, currentRuleModel(), awardId);
        return DefaultChainFactory.StrategyAwardVO.builder()
                .awardId(awardId)
                .logicModel(currentRuleModel())
                .build();
    }

}
